import queue

m,n,q = map(int,input().split())

a = [["." for j in range(0,m)] for i in range(0,n)]

for i in range(0,q):
    caozuo = input().split()
    #画线
    if caozuo[0] == "0":
        y1,x1,y2,x2 = map(int,caozuo[1:])
        x1 = n - 1 - x1
        x2 = n - 1 - x2
        #画横线
        if x1 == x2:
            if y1 > y2:
                temp = y1
                y1 = y2
                y2 = temp
            i = x1
            for j in range(y1,y2 + 1):
                if a[i][j] == "|" or a[i][j] == "+":
                    a[i][j] = "+"
                else:
                    a[i][j] = "-"
        #画竖线
        else:
            if x1 > x2:
                temp = x1
                x1 = x2
                x2 = temp
            j = y1
            for i in range(x1,x2 + 1):
                if a[i][j] == "-" or a[i][j] == "+":
                    a[i][j] = "+"
                else:
                    a[i][j] = "|"
    #填充
    else:
        y,x = map(int,caozuo[1:3])
        x = n - 1 - x
        c = caozuo[3]

        q = queue.deque()
        q.append([x,y])
        while len(q) > 0:
            now = q.popleft()
            i,j = now[:]
            if i < 0 or j < 0 or i >= n or j >= m:
                continue
            if a[i][j] == "-" or a[i][j] == "|" or a[i][j] == "+" or a[i][j] == c :
                continue
            a[i][j] = c
            q.append([i + 1,j])
            q.append([i - 1,j])
            q.append([i,j - 1])
            q.append([i,j + 1])


for row in a:
    for col in row:
        print(col,end="")
    print("")